//表头之间赋值：在项目状态变更中，当选择【暂停、关闭、重启】时， 【变更任务类型】默认显示【项目计划】
if($this.model === "66a670868162426d06b821e7a65d4947" || $this.model === "7aae5b655b98848ebf54f41f14e09de1" || $this.model === "6dc8fdd57b414e2711d8be145fc4ccd6"){
     $this.formModel.select_1755839059585_lB0mS = ["ae7e345ca8fd76827a3590e038efb94b"]; //【注：发送值与接受值的类型匹配才能触发成功,Vue 的 v-model 或响应式数据中操作，确保赋值的是数组类型：】
}

//表头之间赋值：在项目状态变更中，当选择【暂停、关闭、重启】时， 【变更任务类型】默认显示【项目计划】
if($this.model === "beab787a68b38719d784644e0c611cb5" || $this.model === "a1bfcf81bde19573776a00ea0361b384" || $this.model === "d7595e88d8fd545fdd044daa7db8fd52"){
    $this.formModel.select_1755839783610_CUKMl = ["a5e1a504941c1732ee44847e2299fc1c"]; //【注：发送值与接受值的类型匹配才能触发成功,Vue 的 v-model 或响应式数据中操作，确保赋值的是数组类型：】
    console.log($this.formModel.select_1755839783610_CUKMl)
}

console.log("项目状态变更-审批后脚本")
//并且在任务模块的状态相对应改动
//判断 变更状态为 暂停，关闭，重启 时
if ($this.model["select_1690186777289_NxOJa"] == "7aae5b655b98848ebf54f41f14e09de1" || $this.model["select_1690186777289_NxOJa"] == "6dc8fdd57b414e2711d8be145fc4ccd6" || $this.model["select_1690186777289_NxOJa"] == "66a670868162426d06b821e7a65d4947"){
    //变更任务类型存在，变更任务类型（数组）长度>0
    if ($this.model["select_1755839059585_lB0mS"] && $this.model["select_1755839059585_lB0mS"].length>0){
        // let rwlx = ""
        // //收集变更任务类数组的值，用`,`拼接
        // for (let i = 0; i < $this.model["select_1755839059585_lB0mS"].length; i++) {
        //     rwlx += $this.model["select_1755839059585_lB0mS"][i]+","
        // }
        let formData = new FormData();
        let tempWhere = [{
            "key": $this.$util.uuid(),
            "str": "input_1718345101976_ZNGth", //新建任务-项目编号
            "condition": "eq",
            "t_value": $this.model["input_1690186769700_Ra0Vc"], //项目状态变更-项目编号
            "whId": "6f8186cde705b5893e438b42173d6b8d", //新建任务-后台url
            "type": "head"
        }
        //,
        //     {
        //     "key": $this.$util.uuid(),
        //     "str": "select_1711505903223_YWk8w",//新建任务-任务类型
        //     "condition": "in",
        //     "t_value": rwlx,//项目状态变更-任务类型
        //     "whId": "6f8186cde705b5893e438b42173d6b8d", //新建任务-后台url
        //     "type": "head"
        // }
        ]

        //关闭的任务状态为6
        if($this.model["select_1690186777289_NxOJa"] == "6dc8fdd57b414e2711d8be145fc4ccd6"){
            tempWhere.push({
                "key": $this.$util.uuid(),
                "str": "input_1711518795031_xvIfW",//新建任务-任务状态
                "condition": "eq",
                "t_value": "6",
                "whId": "6f8186cde705b5893e438b42173d6b8d",
                "type": "head"
            })
        }
        formData.append("where", JSON.stringify(tempWhere));
        formData.append("authority", "false");
        // 根据表单应用标识- 没进去？
        $this.$http.post('/wind/tableByWhId/6f8186cde705b5893e438b42173d6b8d', formData).then(res => {
            if (res.data.code === 280) {
                let data = res.data.list;
                if (data.length>0){
                    let ids = ""
                    let status = ""
                    if ($this.model["select_1690186777289_NxOJa"] == "7aae5b655b98848ebf54f41f14e09de1"){ //变更状态为暂停
                        status = "5"
                    }else if($this.model["select_1690186777289_NxOJa"] == "6dc8fdd57b414e2711d8be145fc4ccd6"){ //变更状态为关闭
                        status = "7"
                    }else if($this.model["select_1690186777289_NxOJa"] == "66a670868162426d06b821e7a65d4947"){ //变更状态为重启
                        status = "6"
                    }
                    for (let i = 0; i < data.length; i++) {
                        ids+=data[i]["bill_id"]+","
                    }
                    console.log("ids = ",ids);
                    let url = $this.$util.getAPI_URL();
                    let formData=new FormData();
                    formData.append("idList",ids);
                    formData.append("status",status);
                    url = url.replace("api", "task/updateTaskStatus");
                    $this.$http.post(url,formData).then((res) => {
                        if(res.data.code===280){
                            $this.$message.success("修改成功")
                        }else{
                            $this.$message.error("修改失败")
                        }
                    })
                }
            } else {
                $this.$message.error(res.data.msg ? res.data.msg : $this.$t('result.error.common.msg'));
            }
        }).catch(e => {
            $this.$message.error(e.message);
        });

    }
}

